﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using DotNetUI.Models;

namespace DotNetUI.Controls
{
    /// <summary>
    /// DotNet聊天控件元素
    /// </summary>
    public class DotNetChatControlItem : Control, IChatLog
    {
        static DotNetChatControlItem()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(DotNetChatControlItem), new FrameworkPropertyMetadata(typeof(DotNetChatControlItem)));
        }
        public static readonly DependencyProperty ContentTypeProperty = DependencyProperty.Register(nameof(ContentType), typeof(ContentType), typeof(DotNetChatControlItem));
        public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(nameof(Status), typeof(object), typeof(DotNetChatControlItem));
        public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(nameof(Caption), typeof(object), typeof(DotNetChatControlItem));
        public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(object), typeof(DotNetChatControlItem));
        public static readonly DependencyProperty AlignmentProperty=DependencyProperty.Register(nameof(Alignment),typeof(HorizontalAlignment),typeof(DotNetChatControlItem));
        public static readonly DependencyProperty DateTimeProperty= DependencyProperty.Register(nameof(DateTime), typeof(DateTime), typeof(DotNetChatControlItem));
        public static readonly DependencyProperty RespondMessageProperty= DependencyProperty.Register(nameof(RespondMessage), typeof(string), typeof(DotNetChatControlItem));
        /// <summary>
        /// 内容
        /// </summary>
        public object Content { get=>(string)GetValue(ContentProperty); set=>SetValue(ContentProperty,value); }
        /// <summary>
        /// 对其方式
        /// </summary>
        public HorizontalAlignment Alignment { get => (HorizontalAlignment)GetValue(AlignmentProperty); set => SetValue(AlignmentProperty, value); }
        /// <summary>
        /// 时间
        /// </summary>
        public DateTime DateTime { get => (DateTime)GetValue(DateTimeProperty); set => SetValue(DateTimeProperty, value); }
        /// <summary>
        /// 消息内容
        /// </summary>
        public string RespondMessage { get => (string)GetValue(RespondMessageProperty); set => SetValue(RespondMessageProperty, value); }
        /// <summary>
        /// 标题
        /// </summary>
        public object Caption { get => (object)GetValue(CaptionProperty); set => SetValue(CaptionProperty, value); }
        /// <summary>
        /// 状态属性
        /// </summary>
        public object Status { get => (object)GetValue(StatusProperty); set => SetValue(StatusProperty, value); }
        /// <summary>
        /// 内容类型
        /// </summary>
        public ContentType ContentType { get => (ContentType)GetValue(ContentTypeProperty); set => SetValue(ContentTypeProperty, value); }

        public static readonly DependencyProperty HightLightProperty = DependencyProperty.Register(nameof(HightLight),typeof(Langugage),typeof(DotNetChatControlItem));
        public Langugage HightLight { get => this.GetValue<Langugage>(HightLightProperty); set => SetValue(HightLightProperty, value); }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
          var view=     (DotNetCodeViewer)this.Template.FindName("_DotNetCodeViewer", this);
            if (view != null)
            {
                view.SetLangugage(HightLight);
            }
        }
    }
}
